<?php
/**
 * mysql.php
 *
 * @author  zen <gtcfla@gmail.com>
 * @date    2017/9/6
 */

class mysql
{
    // 保存实例的静态成员
    private static $_instance;
    private static $_conn;

    private function __construct()
    {
    }

    static public function getInstance()
    {
        if (!(self::$_instance instanceof self))
        {
            self::$_instance = new self ();
        }
        return self::$_instance;
    }

    public function connect()
    {
        if (! self::$_conn)
        {
            self::$_conn = mysqli_connect('192.168.0.113', 'root', 'play800', 'play800');
            if (! self::$_conn) die ( '连接失败  ' . mysqli_error() );
        }
        return self::$_conn;
    }
}